<?php

	require_once 'googleOptions.php';
	require_once 'googleSearch.php';
	require_once 'searchParser.php';
	require_once 'searchPager.php';


	$q			=	preg_replace('#%#','',$_POST['term']);
	
	if (empty($q) || is_null($q)) die('<h1>Invalid search term</h1>');

	$search	=	new googleSearch();							//An instance of our search proxy
	$search->setQuery($q);										//Search term, usually, something like user input
	$search	=	$search->doGoogleSearch();					//Do the search!

	try { 

		$template	=	new searchParser($search,'resources/templates/');	//Parse the search, 
		$template	=	$template->getSmartyObject();		//Get the Smarty Object!;

		echo $template->fetch ('search.tpl');				//Display The contents

	} catch (Exception $e) {

		var_dump($e->getMessage());							//dump the error, if any

	}

?>
